﻿using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Camc.Quality.PadSocket
{
    public  class TcpMessage
    {
        public TcpMessageType MessageType;
        public string Message;
        public object Data1;
        public object Data2;
        public object Data3;

        public TcpMessage(TcpMessageType MessageType, string Message = "", object Data1 = null, object Data2 = null, object Data3 = null)
        {
            this.MessageType = MessageType;
            this.Message = Message;
            this.Data1 = Data1;
            this.Data2 = Data2;
            this.Data3 = Data3;
        }

        public Byte[] ToJsonByte()
        {
            return Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(this) + "\r\n");
        }
    }

    public enum TcpMessageType
    {
        PortBroadcast,
        Message,
        SendFile,
        Error,
        DeviceConnect,
        DeviceDisConnect
    }
}
